<?php

namespace app\middleware;

use app\BaseController;
use think\facade\Cache;

class Check extends BaseController
{
    public function handle($request, \Closure $next)
    {
        $token = $request->header('Authorization','');
        $request->cacheInfo=Cache::store('redis')->get($token);
        if (empty($request->cacheInfo)){
            return $this->returnJson(self::NOT_LOGGED,'未登录,跳转登录页');
        }
        $request->user_id=$request->cacheInfo['id'];
        $request->class_id=$request->cacheInfo['class_id'];
        return  $next($request);
    }
}